#include <iostream>

using namespace std;

const int N = 10;
int a[N][N];
bool row[N][N], col[N][N], squ[N][N][N];

bool dfs(int i, int j)
{
	if(j == 9)
	{
		i++;
		j = 0;
	}
	if(i == 9) return true;
	if(a[i][j]) return dfs(i, j + 1);
	
	for(int x = 1; x <= 9; x++)
	{
		if(row[i][x] || col[j][x] || squ[i / 3][j / 3][x]) continue;
		a[i][j] = x;
		row[i][x] = col[j][x] = squ[i / 3][j / 3][x] = true;
		if(dfs(i, j + 1)) return true;
		a[i][j] = 0;
		row[i][x] = col[j][x] = squ[i / 3][j / 3][x] = false;
		
	}
	return false;
}

int main()
{
	for(int i = 0; i < 9; i++)
	{
		for(int j = 0; j < 9; j++)
		{
			cin >> a[i][j];
			if(a[i][j])
			{
				row[i][a[i][j]] = true;
				col[j][a[i][j]] = true;
				squ[i / 3][j / 3][a[i][j]] = true;
			}
		}
	}
	
	dfs(0, 0);
	
	for(int i = 0; i < 9; i++)
	{
		for(int j = 0; j < 9; j++)
		{
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
	
	return 0;
 } 
